﻿using Kaskelot.SP.Model.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;

namespace Kaskelot.SP.Services.Client
{
    [ServiceContract(Namespace = "http://Kaskelot.SP.Services")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class ClientNavigationService : BaseClientService
    {
        [OperationContract]
		[WebGet(BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
		public ClientServiceResult<IEnumerable<MenuItem>> GetToolboxItems(string toolboxConfigId)
        {
            ClientServiceResult<IEnumerable<MenuItem>> csr = new ClientServiceResult<IEnumerable<MenuItem>>();

            try
            {
                NavigationService svc = new NavigationService();
                csr.Data = svc.GetToolboxItems(toolboxConfigId);
            }
            catch (Exception ex)
            {
                csr.ErrorMessage = ex.Message;
                csr.HasError = true;
            }

            return csr;
        }
    }
}
